var oneChanneli = document.getElementById("oneChannelValue").value;
var twoChanneli = document.getElementById("twoChannelValue").value;
var thrChanneli = document.getElementById("thrChannelValue").value;
var ChannelList;
$.post(Feng.ctxPath + "/channel/getChannelssd", function (data) {
    ChannelList = data;
    channelInit('oneChannel', 'twoChannel', 'thrChannel');
    $("#oneMedium").val($("#oneChannel").val());
    $("#twoMedium").val($("#twoChannel").val());
    $("#thrMedium").val($("#thrChannel").val());
}, "json");

function getArchiving () { // 选择建档人
    var index = parent.layer.open({
        type: 2,
        title: '选中建档人',
        area: ['70%', '60%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/reservations/to_archiving2',
        end:function () {
            $("#archiving").val($('#archivingValue', parent.document).val());
        }
    });
    this.layerIndex = index;
};

function replenishment() { // 补单提交
    var reservationsId = $("#reservationsId").val();
    var userName = $("#userName").val();
    var oneChannel = $("#oneChannel").val();
    var twoChannel = $("#twoChannel").val();
    var thrChannel = $("#thrChannel").val();
    var archiving = $("#archiving").val();
    if (archiving == null || archiving == "" ) {
        alert("请选择建档人！");
        return;
    }
    var filingTime = $("#filingTime").val();
    if (filingTime == null || filingTime == "" ) {
        alert("请填写建档时间！");
        return;
    }
    if (oneChannel == null || oneChannel == "请选择" || twoChannel == null || twoChannel == "请选择" || thrChannel == null || thrChannel == "请选择") {
        alert("请选择渠道！");
        return;
    }
    $.ajax({
        url: Feng.ctxPath + "/reservations/supplementok",
        type: "post",
        data: {
            "oneChannel": oneChannel,
            "twoChannel": twoChannel,
            "thrChannel": thrChannel,
            "archiving": archiving,
            "filingTime": filingTime,
            "reservationsId": reservationsId,
            "userName": userName
        },
        success: function (data) {
            if(data==0){
                alert('此患者已存在!');
            }else{
                alert('操作成功!');
            }
            window.parent.ReservationsStoreRecordsTable.table.refresh();
            $('#cancel', document).click();
        },
        error: function (data) {
            alert('没有权限，请联系系统管理员!');
            $('#cancel', document).click();
        }
    });
};

$("#customerPhoneAdd").click(function () {
    $(".dianhua").toggle();
});

$("#oneChannel").change(function () {
    setTimeout(function () {
        $("#oneMedium").val($("#oneChannel").val());
        $("#twoMedium").val($("#twoChannel").val());
        $("#thrMedium").val($("#thrChannel").val());
    }, 100);
});

$("#twoChannel").change(function () {
    setTimeout(function () {
        $("#oneMedium").val($("#oneChannel").val());
        $("#twoMedium").val($("#twoChannel").val());
        $("#thrMedium").val($("#thrChannel").val());
    }, 100);
});

$("#thrChannel").change(function () {
    setTimeout(function () {
        $("#oneMedium").val($("#oneChannel").val());
        $("#twoMedium").val($("#twoChannel").val());
        $("#thrMedium").val($("#thrChannel").val());
    }, 100);
});